package com.guigu.service.impl;

import com.guigu.dto.motion_summaryDTO;
import com.guigu.mapper.motion_summaryMapper;
import com.guigu.service.motion_summaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

@Service
public class motion_summaryServiceImpl implements motion_summaryService {
    @Autowired
    private motion_summaryMapper motion_summary;

    @Override
    @Transactional
    public void saveMotion_summary(motion_summaryDTO dto) {
        this.motion_summary.saveMotion_summary(dto);
        LocalDateTime currentDateTime = LocalDateTime.now(); // 获取当前系统时间

        // 将当前时间转换为 Date 类型
        Instant instant = currentDateTime.atZone(ZoneId.systemDefault()).toInstant();
        Date currentDate = Date.from(instant);
        dto.setI_time(currentDate);
        this.motion_summary.saveIntervention(dto);
        this.motion_summary.saveMotion(dto);
        this.motion_summary.saveMotion_movement(dto);
        this.motion_summary.saveMeals(dto);
        this.motion_summary.saveMeals_meal(dto);


    }
}
